﻿using System;

namespace TierraReborn
{
    public class Soup
    {
        private static Soup _singleton = new Soup();
        public static Soup GetSingleton()
        {
            return _singleton;
        }

        private Soup() {}


        private const int Max = 60000;
        private MachineInstruction.InstructionEnum[] _instructions = new MachineInstruction.InstructionEnum[Max];

        internal void Set(int index, MachineInstruction.InstructionEnum instruction)
        {
            _instructions[index] = instruction;
        }

        internal MachineInstruction.InstructionEnum Get(int index)
        {
            return _instructions[index];
        }

        public int GetMax()
        {
            return Max;
        }


        public void Allocate(Creature  crature)
        {
            // add exclusive write for this creature

            
        }

        public void Deallocate(Creature creature)
        {
            // remove exclusive write for the creature
        }

        // Something to allocate for children during copy

        public void BackgroundMutation()
        {
            // Random flip bits in instructions
            // ex. 1 mutation for each 10000 operations executed
        }

        public void Copy(Creature executer, int from, int to)
        {
            // Check exclusive write for executer

            // MUTATION
            // copy mutation rate 1 for every 1000/2500
        }
    }
}
